<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/plugins/vue/dist/vue.min.js"></script>
    <script src="js/plugins/axios/dist/axios.min.js"></script>
    <script src="js/common.js"></script>
</head>
<body>
<div id="app"></div>
</body>
<script>
    new Vue({
        el:"#app",
        data:{

        },
        methods:{
            //把code发送到后台  (账户的安全)
            //后台发送请求获取 access_token
            getAccessToken(){
                //获取当前页面的url uri  获取？后面的参数  code
                var param = getURLParam();
                //发送请求 把code发送到后台
                this.$http.post('/wxUser/wxUserLogin',param).then(res=>{
                    console.log(res,"res")
                    if(res.data.success){
                        //1.浏览器存储 token  存储loginInfo
                        localStorage.setItem("token",res.data.resultObj.TOKEN)
                        localStorage.setItem("loginInfo",JSON.stringify(res.data.resultObj.loginInfo))
                        //2.跳转到首页
                        location.href="/index.html"
                    }
                    else {
                        location.href=res.data.resultObj
                    }

                })

            }
        },
        mounted(){
            this.getAccessToken();
        }

    })

</script>
</html>